using System;
using System.Collections.Generic;
using System.Text;
using LispLib;

namespace GeneticAlgorithm.CP3.ParseTree
{
    class Mutation
    {
        public static Individual<Interpreter.Pair, Interpreter.Pair> A(Individual<Interpreter.Pair, Interpreter.Pair> parent)
        {
            Interpreter.Pair genotype = Crossover.Duplicate(parent.Genotype);
            List<Interpreter.Pair> list = new List<Interpreter.Pair>();
            Crossover.Flatten(genotype, list, new Interpreter());

            Interpreter.Pair spot = list[Global.random.Next(list.Count)];

            spot.car_ = Global.random.Next(1, 11);
            /*
            if (spot.cdr_ == null || Global.random.Next(0, 2) == 0)
            {
                spot.car_ = Global.random.Next(0, 11);
            }
            else
            {
                spot.cdr_ = Global.random.Next(0, 11);
            }
            */

            return new Individual(genotype, parent);
        }
    }
}
